/* eslint-disable */

// const _ = n("b605");

// n = {
//   url: "https://3pp.starbucks.com.cn/wxmem/index/global/config",
//   data: {},
//   method: "GET",
// };

// n[w(342)][w(472)]() = get
// const q = Object(_.p)(n.data, n[w(342)][w(472)]());

// ////////////////////////

function A(e, t) {
  var n = M();
  return (A = function(t, r) {
      var a = n[t -= 321];
      if (void 0 === A.tTHZGc) {
          var o = function(e) {
              for (var t, n, r = "", a = "", o = 0, i = 0; n = e.charAt(i++); ~n && (t = o % 4 ? 64 * t + n : n, o++ % 4) ? r += String.fromCharCode(255 & t >> (-2 * o & 6)) : 0) n = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(n);
              for (var s = 0, c = r.length; s < c; s++) a += "%" + ("00" + r.charCodeAt(s).toString(16)).slice(-2);
              return decodeURIComponent(a)
          };
          A.lFXJTT = o, e = arguments, A.tTHZGc = !0
      }
      var i = n[0],
          s = t + i,
          c = e[s];
      return c ? a = c : (a = A.lFXJTT(a), e[s] = a), a
  })(e, t)
}
function M() {
  var e = ["yKTis00", "AMzrru0", "CMvWBgfJzq", "yuP0t2O", "Ec13Ec1LBMnYExb0lw9Wzw5Pza", "EgLyt2m", "mteXnZKXmLLxyuHbqW", "y29TBwL0", "A1zstKK", "y2PHq0W", "BwvZC2fNzq", "wNnrDKi", "BgfWwMm", "AgLKzq", "t09VyNC", "mZeYnZy3mtn4qwnmwwK", "CgfYC2u", "DgDxz1y", "zLPOu1C", "s3LQyxO", "Bvziuui", "tK9FseforeXf", "EwzHrw0", "ue9tva", "BwLUAxbYB2DYyw0", "zgvS", "rvz4sxK", "z3jHEq", "EKD3CLe", "C3rN", "p3nPz249", "C3rHDhvZq29Kzq", "C2HVD1rVyxn0", "CMfUzg9T", "ufjfvKvovc1fvKvova", "AvH6zfG", "DfPZAKu", "ENrgD08", "A0LqCg4", "tKjMqNe", "BLnlC1a", "qLfMrLa", "rMDisvm", "s1HduLO", "B2n0Cu4", "Dg9Rzw46", "z2v0u3rVCMfNztPMywLSigrHDgeGBM90igzVDw5K", "CMvXDwvZDf9HzNrLCL9ZDwnJzxnZ", "weHLy0C", "ChjVBxb0x3rVyxn0", "C2v0u3rVCMfNzq", "ze55uvq", "B3rOzxiVBg9NAw4VDhjVDwjSzq", "Bg9NAw4VDJeVBg9NAw5pCLjLz2LZDa", "zgf0yq", "BuDyyKm", "nJa1zLveELjw", "mJqXodK2CvfjBure", "veTNA2q", "CMvXDwvZDf9IzwzVCMu", "tvnpsLa", "uMfVzM4", "su1zwKm", "sLz2v0O", "C0jHwM8", "AgvHzgvY", "tKT3Ae4", "vxLewge", "wMj1wMy", "y29Kzq", "qK9IDgG", "y2v3B1C", "rg1lv1G", "tKXkA28", "Dg9mB3DLCKnHC2u", "mZuYD1zxCLD3", "z3fZtKC", "y2fJAgu6", "CMvXDwvZDf9HzNrLCL9LCNjVCG", "zM9Yy2vdywnOzq", "rurZExK", "D01RsLu", "weDKr2G", "wxP0twy", "ufvu", "Bg9NAw4Vy2HLy2TnB2jPBgu", "BfDsvMK", "Chv0", "zgrJsLK", "A29Uz09WDgLVBG", "Bg9NAw4VyxbPl3D4l3yXl2fJy291BNqVCMvNAxn0zxi", "EMrKwvy", "C2HVD01VzgfS", "ntG0mwfOEg1PAa", "ALnkuhy", "wxvOzxa", "zxjYtxnN", "ELPOwLG", "BNvTyMvY", "wuzsEfu", "C2HVD0nSB3n1CMvdB21WB25LBNrZ", "Bwf0y2G", "DMvYExn0yxiMC2H1Aw5MBW", "wvH1DKq", "Be5bAxC", "C3LIC0O", "DwrUzwe", "s2HRrLq", "v0vjweLox01jtKLFuKvrvuvtvf9brLrfuL9tvundrvntx0Xpr1m", "rvnpq0Tfvfrjtuvet1vu", "tK5Uzg0", "CgLVtem", "nteZmeviyvDZDa", "Ahr0Chm6lY8ZChaUC3rHCMj1y2TZlMnVBs5JBG", "wgjwwxG", "Cg9hseG", "Ewnus2m", "u05vEwO", "C2zXu3a", "zxjYB3jdB21Wzw5ZyxrLrM4", "z2v0", "Cw9dB2y", "Bwv0Ag9K", "tKvRB2S", "y29TCgvUC2f0zvrHyMXL", "CMvXDwvZDa", "uMnbEg0", "C3bSAxq", "ndK0odLetNP3wve", "C3r1zgvUDfjPz2H0CY9NzxrtDhvKzw50sw5MBW", "C3rYAw5NAwz5", "AxnszwPLy3reyxrH", "x3jLCxvLC3q", "t3jPz2LU", "DgLTzxn0yw1W", "AxnhB0LUzgv4", "y2fJAgvgBG", "CM1JwLu", "tK9erv9dvvnut01Fru5w", "veLMsfG", "Aw5KzxHpzG", "mY40lJa", "Aw5LC2m", "C2HVDW", "tNLry0S", "vNbcDwK", "mtK3otrvzvLPwvu", "ufz1tLa", "zw50CNLmB3DsAxnR", "Bwf2D0G", "yujPtMq", "y29TBw9U", "AfHRu2m", "B3LUA3m", "nNruBezcCW", "DgrwC2u", "t1ftBxG", "C3rHDgu", "B3rOs2O", "y29UzMLYBq", "wwPjyuG", "r0X1ww8", "AxnmB2DPBG", "C2HVD1rVyxn0rM4", "s29cDg8", "yxLACMm", "v0vjweLox01jtKLFuKvrvuvtvf9brLrfuL9fuLjpuL9mt0Dt", "z3z3CLe", "mJjIrhzuu3u", "Efzpuxm", "zu9REuG", "nZy1mtDWruPQtem", "whzSsNy", "5PIV5zcM5y675Asn5yI26zsz6k+V5l+H5OgV77YF", "BgvUz3rO", "z1noEwq", "C3rVCMuUC3rHDguUy29TBw9UlMLZtg9NAw4GoJ4+ia", "ndHvqwfivLm"];
  return (M = function() {
      return e
  })()
}! function(e, t) {
  for (var n = A, r = e();;) try {
      if (604357 == parseInt(n(348)) / 1 * (-parseInt(n(397)) / 2) + -parseInt(n(374)) / 3 * (-parseInt(n(404)) / 4) + parseInt(n(454)) / 5 * (-parseInt(n(366)) / 6) + -parseInt(n(391)) / 7 * (parseInt(n(473)) / 8) + -parseInt(n(491)) / 9 * (parseInt(n(332)) / 10) + -parseInt(n(388)) / 11 * (-parseInt(n(455)) / 12) + parseInt(n(413)) / 13) break;
      r.push(r.shift())
  } catch (e) {
      r.push(r.shift())
  }
}(M);
function C() {
  var e = ["yK92yu4", "BwvTyMvY", "A3nSu1a", "CM91Dgu", "Aw5KzxHpzG", "Bg9NAw5bDxrOtMfTzq", "t29dshm", "DxnLCKLZqxv0AeXVy2f0Aw9U", "nda5ndi4ohj4wMPxAW", "ruPYq0C", "mJi3CejwBKf0", "thjdCvm", "ve1Augi", "uhL2zwS", "y29UzMLN", "sKfhsgK", "tNnSCMy", "zgfvCfa", "suPXB1K", "z2v0u2v0DgLUzW", "DxnLCKXVz2LU", "ExftC2S", "Dg9Rzw4", "zLbMq3G", "B2Hft2K", "DxnLCG", "Dg9Rzw7KUi3OG73KUlRNQBRVVie", "sfnoBeW", "ntaWndG3r1HOBxje", "Cgf0Aa", "vMPSzNq", "nZy5mdq3mNPXA3vXwq", "Bg9NAw5bDxrO", "BgvUz3rO", "ALryuvC", "y1vyvg8", "uwj5vLa", "Cgrzvxy", "ru9KC0u", "DxnLCLr5Cgu", "C2nVCguUDxnLCKXVy2f0Aw9U", "z2v0tg9NAw5qCM9JzxnZrgf0yq", "whjezfu", "zvnlyuC", "DxnLCLr5CgvqyxrO", "whziA3O", "sML1B0u", "rMzcALG", "Ew5hDxG", "A2v5CW", "zgf0yq", "yxv0AfnLDhrPBMC", "mJK5odqWnu1ouer4sq", "B29ZELC", "AKvMANO", "mtbVsuXlAMK", "EeTlBuG", "AM9PBG", "Aw5iExu", "y29TBw9U", "ruruy1K", "vu9ctMC", "Bg9NB3v0", "yxv0AevYCLrVsw5KzxG", "y29TBwL0", "sgnNr0q", "Bg9JAW", "rxjNtMS", "wfzTt2O", "EMPfyuu", "CgfNzxm", "C2v0u3rVCMfNzq", "ChvZAa", "C3rHDgu", "zhLfENK", "C3rYAw5NAwz5", "v2rJsKe", "ExjguMC", "C3DPDgnOvxnLCKvUDhj5vhLWzq", "uvfnz1u", "vfDnAMe", "zMLUywXSEq", "z2v0", "u0HPDu0", "EgL6ANm", "nNv4tMTqrW", "nJeYodu2m013C0vbEq", "z2v0q29UzMLN", "mty2nZm0oxrls2fOsW", "z2v0vg9Rzw4", "uLPsr2q", "otq1ogzezu9rCq", "yuj2u0m", "yNvRAui", "uNrJC1y", "BgXkENK", "Aw5KzxG", "AvHbswS", "y2H6s00", "C29YDa"];
  return (C = function() {
      return e
  })()
}! function(e, t) {
  for (var n = P, r = e();;) try {
      if (545360 == -parseInt(n(439)) / 1 * (-parseInt(n(420)) / 2) + parseInt(n(457)) / 3 + -parseInt(n(437)) / 4 + -parseInt(n(481)) / 5 * (-parseInt(n(414)) / 6) + parseInt(n(415)) / 7 + -parseInt(n(460)) / 8 + parseInt(n(417)) / 9 * (-parseInt(n(484)) / 10)) break;
      r.push(r.shift())
  } catch (e) {
      r.push(r.shift())
  }
}(C);
function P(e, t) {
  var n = C();
  return (S = function(t, r) {
      var a = n[t -= 413];
      if (void 0 === S.ouuPMQ) {
          var o = function(e) {
              for (var t, n, r = "", a = "", o = 0, i = 0; n = e.charAt(i++); ~n && (t = o % 4 ? 64 * t + n : n, o++ % 4) ? r += String.fromCharCode(255 & t >> (-2 * o & 6)) : 0) n = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(n);
              for (var s = 0, c = r.length; s < c; s++) a += "%" + ("00" + r.charCodeAt(s).toString(16)).slice(-2);
              return decodeURIComponent(a)
          };
          S.jhxlhC = o, e = arguments, S.ouuPMQ = !0
      }
      var i = n[0],
          s = t + i,
          c = e[s];
      return c ? a = c : (a = S.jhxlhC(a), e[s] = a), a
  })(e, t)
}
function o(e, t) {
  var n = 31 & t;
  return (e << n) | (e >>> (32 - n));
}
function i(e, t) {
  for (var n = [], r = e.length - 1; r >= 0; r--) n[r] = 255 & (e[r] ^ t[r]);
  return n
}
function s(e) {
  return e ^ o(e, 9) ^ o(e, 17);
}
function c(e) {
  return e ^ o(e, 15) ^ o(e, 23);
}
function asm3(e) {
  var r = []//new Uint32Array(68),
    a = new Uint32Array(64);

    var t = 8 * e.length,
    n = t % 512;
n = n >= 448 ? 512 - n % 448 - 1 : 448 - n - 1;
for (var i = new Array((n - 7) / 8), u = new Array(8), d = 0, p = i.length; d < p; d++) i[d] = 0;
for (var l = 0, f = u.length; l < f; l++) u[l] = 0;
t = t.toString(2);
for (var g = 7; g >= 0; g--)
    if (t.length > 8) {
        var h = t.length - 8;
        u[g] = parseInt(t.substr(h), 2), t = t.substr(0, h)
    } else t.length > 0 && (u[g] = parseInt(t, 2), t = "");
for (var v = new Uint8Array([].concat(e, [128], i, u)), m = new DataView(v.buffer, 0), y = v.length / 64, b = new Uint32Array([1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]), _ = 0; _ < y; _++) {
    r.fill(0), a.fill(0);
    for (var T = 16 * _, k = 0; k < 16; k++) r[k] = m.getUint32(4 * (T + k), !1);
    for (var O = 16; O < 68; O++) r[O] = c(r[O - 16] ^ r[O - 9] ^ o(r[O - 3], 15)) ^ o(r[O - 13], 7) ^ r[O - 6];
    for (var P = 0; P < 64; P++) a[P] = r[P] ^ r[P + 4];
    for (var S = b[0], C = b[1], x = b[2], w = b[3], E = b[4], I = b[5], D = b[6], A = b[7], M = void 0, R = void 0, N = void 0, j = void 0, L = 0; L < 64; L++) j = L >= 0 && L <= 15 ? 2043430169 : 2055708042, R = (L >= 0 && L <= 15 ? S ^ C ^ x : S & C | S & x | C & x) + w + ((M = o(o(S, 12) + E + o(j, L), 7)) ^ o(S, 12)) + a[L], N = (L >= 0 && L <= 15 ? E ^ I ^ D : E & I | ~E & D) + A + M + r[L], w = x, x = o(C, 9), C = S, S = R, A = D, D = o(I, 19), I = E, E = s(N);
    b[0] ^= S, b[1] ^= C, b[2] ^= x, b[3] ^= w, b[4] ^= E, b[5] ^= I, b[6] ^= D, b[7] ^= A
}
for (var B = [], U = 0, F = b.length; U < F; U++) {
    var $ = b[U];
    B.push((4278190080 & $) >>> 24, (16711680 & $) >>> 16, (65280 & $) >>> 8, 255 & $)
}
return B
}

function hmac(e, t) {
  for (t.length > 64 && (t = u(t)); t.length < 64;) t.push(0);
  var n = i(t, d),
      r = i(t, p),
      a = asm3([].concat(n, e));
  return asm3([].concat(r, a))
}

function arrayToHex(x) {
  return x.map(function (e) {
      return 1 === (e = e.toString(16)).length ? "0" + e : e;
    }).join("");
}
function sm3(e, t) {
  console.log('sm3 e', e);
  console.log('sm3 t', t);
  if (
    ((e =
      "string" == typeof e
        ? (function (e) {
            for (var t = [], n = 0, r = e.length; n < r; n++) {
              var a = e.codePointAt(n);
              if (a <= 127) t.push(a);
              else if (a <= 2047)
                t.push(192 | (a >>> 6)), t.push(128 | (63 & a));
              else if (a <= 55295 || (a >= 57344 && a <= 65535))
                t.push(224 | (a >>> 12)),
                  t.push(128 | ((a >>> 6) & 63)),
                  t.push(128 | (63 & a));
              else {
                if (!(a >= 65536 && a <= 1114111))
                  throw (t.push(a), new Error("input is not supported"));
                n++,
                  t.push(240 | ((a >>> 18) & 28)),
                  t.push(128 | ((a >>> 12) & 63)),
                  t.push(128 | ((a >>> 6) & 63)),
                  t.push(128 | (63 & a));
              }
            }
            return t;
          })(e)
        : Array.prototype.slice.call(e)),
    t)
  ) {
    if ("hmac" !== (t.mode || "hmac")) throw new Error("invalid mode");
    var n = t.key;
    if (!n) throw new Error("invalid key");

    return (
      (n = "string" == typeof n ? s(n) : Array.prototype.slice.call(n)),
      arrayToHex(hmac(e, n))
    );
  }
  return arrayToHex(asm3(e));
}

function newSign(e) {
    var t = this,
        n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : P(511),
        r = P,
        a = {
            daUpP: function(e, t) {
                return e instanceof t
            },
            llJzy: function(e, t) {
                return e === t
            },
            bYXCL: r(490),
            WYbwK: r(511)
        },
        o = "";
    if (a[r(424)](n, a.WYbwK)) {
        e = e || {};
        var i = Object[r(478)](e)[r(428)](),
            s = [];
        i.forEach((function(n) {
            var o = r;
            (a[o(446)](e[n], Array) || a.daUpP(e[n], Object)) && (a.llJzy(a.bYXCL, o(422)) ? t[o(491)]() : e[n] = JSON.stringify(e[n])), s.push(n + "=" + e[n])
        })), o = s.join("&")
    } else e && (o = JSON.stringify(e));
    return sm3(o);
}

function getSign(data, method) {
  return newSign(data, method);
};
// const data = {"currentLatitude":24.47118099176537,"currentLongitude":118.0267169515382,"diameter":50000,"latitude":"33.626149","longitude":"114.696951","nonce":0.20482584966158934,"pageNo":1,"pageSize":20}
// const sign = getSign(data, "post");
// console.log('sign', sign)
// const data = {
// type: 'Delivery'
// };
// const sign = getSign(data, "get");
exports.getSign = getSign
